/**
 */
package org.cmoine.perspectiveshare.model.impl;

import java.util.Collection;

import org.cmoine.perspectiveshare.model.FolderType;
import org.cmoine.perspectiveshare.model.PageType;
import org.cmoine.perspectiveshare.model.PerspectivesPackage;
import org.cmoine.perspectiveshare.model.PresentationType;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Folder Type</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.cmoine.perspectiveshare.model.impl.FolderTypeImpl#getPage <em>Page</em>}</li>
 *   <li>{@link org.cmoine.perspectiveshare.model.impl.FolderTypeImpl#getPresentation <em>Presentation</em>}</li>
 *   <li>{@link org.cmoine.perspectiveshare.model.impl.FolderTypeImpl#getActivePageID <em>Active Page ID</em>}</li>
 *   <li>{@link org.cmoine.perspectiveshare.model.impl.FolderTypeImpl#getAppearance <em>Appearance</em>}</li>
 *   <li>{@link org.cmoine.perspectiveshare.model.impl.FolderTypeImpl#getExpanded <em>Expanded</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class FolderTypeImpl extends EObjectImpl implements FolderType {
    /**
     * The cached value of the '{@link #getPage() <em>Page</em>}' containment reference list.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getPage()
     * @generated
     * @ordered
     */
    protected EList<PageType> page;

    /**
     * The cached value of the '{@link #getPresentation() <em>Presentation</em>}' containment reference.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getPresentation()
     * @generated
     * @ordered
     */
    protected PresentationType presentation;

    /**
     * The default value of the '{@link #getActivePageID() <em>Active Page ID</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getActivePageID()
     * @generated
     * @ordered
     */
    protected static final String ACTIVE_PAGE_ID_EDEFAULT = null;

    /**
     * The cached value of the '{@link #getActivePageID() <em>Active Page ID</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getActivePageID()
     * @generated
     * @ordered
     */
    protected String activePageID = ACTIVE_PAGE_ID_EDEFAULT;

    /**
     * The default value of the '{@link #getAppearance() <em>Appearance</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getAppearance()
     * @generated
     * @ordered
     */
    protected static final byte APPEARANCE_EDEFAULT = 0x00;

    /**
     * The cached value of the '{@link #getAppearance() <em>Appearance</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getAppearance()
     * @generated
     * @ordered
     */
    protected byte appearance = APPEARANCE_EDEFAULT;

    /**
     * This is true if the Appearance attribute has been set.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     * @ordered
     */
    protected boolean appearanceESet;

    /**
     * The default value of the '{@link #getExpanded() <em>Expanded</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getExpanded()
     * @generated
     * @ordered
     */
    protected static final byte EXPANDED_EDEFAULT = 0x00;

    /**
     * The cached value of the '{@link #getExpanded() <em>Expanded</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getExpanded()
     * @generated
     * @ordered
     */
    protected byte expanded = EXPANDED_EDEFAULT;

    /**
     * This is true if the Expanded attribute has been set.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     * @ordered
     */
    protected boolean expandedESet;

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    protected FolderTypeImpl() {
        super();
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    protected EClass eStaticClass() {
        return PerspectivesPackage.Literals.FOLDER_TYPE;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public EList<PageType> getPage() {
        if (page == null) {
            page = new EObjectContainmentEList<PageType>(PageType.class, this, PerspectivesPackage.FOLDER_TYPE__PAGE);
        }
        return page;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public PresentationType getPresentation() {
        return presentation;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public NotificationChain basicSetPresentation(PresentationType newPresentation, NotificationChain msgs) {
        PresentationType oldPresentation = presentation;
        presentation = newPresentation;
        if (eNotificationRequired()) {
            ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, PerspectivesPackage.FOLDER_TYPE__PRESENTATION, oldPresentation, newPresentation);
            if (msgs == null) msgs = notification; else msgs.add(notification);
        }
        return msgs;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public void setPresentation(PresentationType newPresentation) {
        if (newPresentation != presentation) {
            NotificationChain msgs = null;
            if (presentation != null)
                msgs = ((InternalEObject)presentation).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - PerspectivesPackage.FOLDER_TYPE__PRESENTATION, null, msgs);
            if (newPresentation != null)
                msgs = ((InternalEObject)newPresentation).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - PerspectivesPackage.FOLDER_TYPE__PRESENTATION, null, msgs);
            msgs = basicSetPresentation(newPresentation, msgs);
            if (msgs != null) msgs.dispatch();
        }
        else if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.SET, PerspectivesPackage.FOLDER_TYPE__PRESENTATION, newPresentation, newPresentation));
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public String getActivePageID() {
        return activePageID;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public void setActivePageID(String newActivePageID) {
        String oldActivePageID = activePageID;
        activePageID = newActivePageID;
        if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.SET, PerspectivesPackage.FOLDER_TYPE__ACTIVE_PAGE_ID, oldActivePageID, activePageID));
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public byte getAppearance() {
        return appearance;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public void setAppearance(byte newAppearance) {
        byte oldAppearance = appearance;
        appearance = newAppearance;
        boolean oldAppearanceESet = appearanceESet;
        appearanceESet = true;
        if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.SET, PerspectivesPackage.FOLDER_TYPE__APPEARANCE, oldAppearance, appearance, !oldAppearanceESet));
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public void unsetAppearance() {
        byte oldAppearance = appearance;
        boolean oldAppearanceESet = appearanceESet;
        appearance = APPEARANCE_EDEFAULT;
        appearanceESet = false;
        if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.UNSET, PerspectivesPackage.FOLDER_TYPE__APPEARANCE, oldAppearance, APPEARANCE_EDEFAULT, oldAppearanceESet));
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public boolean isSetAppearance() {
        return appearanceESet;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public byte getExpanded() {
        return expanded;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public void setExpanded(byte newExpanded) {
        byte oldExpanded = expanded;
        expanded = newExpanded;
        boolean oldExpandedESet = expandedESet;
        expandedESet = true;
        if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.SET, PerspectivesPackage.FOLDER_TYPE__EXPANDED, oldExpanded, expanded, !oldExpandedESet));
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public void unsetExpanded() {
        byte oldExpanded = expanded;
        boolean oldExpandedESet = expandedESet;
        expanded = EXPANDED_EDEFAULT;
        expandedESet = false;
        if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.UNSET, PerspectivesPackage.FOLDER_TYPE__EXPANDED, oldExpanded, EXPANDED_EDEFAULT, oldExpandedESet));
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public boolean isSetExpanded() {
        return expandedESet;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
        switch (featureID) {
            case PerspectivesPackage.FOLDER_TYPE__PAGE:
                return ((InternalEList<?>)getPage()).basicRemove(otherEnd, msgs);
            case PerspectivesPackage.FOLDER_TYPE__PRESENTATION:
                return basicSetPresentation(null, msgs);
        }
        return super.eInverseRemove(otherEnd, featureID, msgs);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public Object eGet(int featureID, boolean resolve, boolean coreType) {
        switch (featureID) {
            case PerspectivesPackage.FOLDER_TYPE__PAGE:
                return getPage();
            case PerspectivesPackage.FOLDER_TYPE__PRESENTATION:
                return getPresentation();
            case PerspectivesPackage.FOLDER_TYPE__ACTIVE_PAGE_ID:
                return getActivePageID();
            case PerspectivesPackage.FOLDER_TYPE__APPEARANCE:
                return getAppearance();
            case PerspectivesPackage.FOLDER_TYPE__EXPANDED:
                return getExpanded();
        }
        return super.eGet(featureID, resolve, coreType);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @SuppressWarnings("unchecked")
    @Override
    public void eSet(int featureID, Object newValue) {
        switch (featureID) {
            case PerspectivesPackage.FOLDER_TYPE__PAGE:
                getPage().clear();
                getPage().addAll((Collection<? extends PageType>)newValue);
                return;
            case PerspectivesPackage.FOLDER_TYPE__PRESENTATION:
                setPresentation((PresentationType)newValue);
                return;
            case PerspectivesPackage.FOLDER_TYPE__ACTIVE_PAGE_ID:
                setActivePageID((String)newValue);
                return;
            case PerspectivesPackage.FOLDER_TYPE__APPEARANCE:
                setAppearance((Byte)newValue);
                return;
            case PerspectivesPackage.FOLDER_TYPE__EXPANDED:
                setExpanded((Byte)newValue);
                return;
        }
        super.eSet(featureID, newValue);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public void eUnset(int featureID) {
        switch (featureID) {
            case PerspectivesPackage.FOLDER_TYPE__PAGE:
                getPage().clear();
                return;
            case PerspectivesPackage.FOLDER_TYPE__PRESENTATION:
                setPresentation((PresentationType)null);
                return;
            case PerspectivesPackage.FOLDER_TYPE__ACTIVE_PAGE_ID:
                setActivePageID(ACTIVE_PAGE_ID_EDEFAULT);
                return;
            case PerspectivesPackage.FOLDER_TYPE__APPEARANCE:
                unsetAppearance();
                return;
            case PerspectivesPackage.FOLDER_TYPE__EXPANDED:
                unsetExpanded();
                return;
        }
        super.eUnset(featureID);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public boolean eIsSet(int featureID) {
        switch (featureID) {
            case PerspectivesPackage.FOLDER_TYPE__PAGE:
                return page != null && !page.isEmpty();
            case PerspectivesPackage.FOLDER_TYPE__PRESENTATION:
                return presentation != null;
            case PerspectivesPackage.FOLDER_TYPE__ACTIVE_PAGE_ID:
                return ACTIVE_PAGE_ID_EDEFAULT == null ? activePageID != null : !ACTIVE_PAGE_ID_EDEFAULT.equals(activePageID);
            case PerspectivesPackage.FOLDER_TYPE__APPEARANCE:
                return isSetAppearance();
            case PerspectivesPackage.FOLDER_TYPE__EXPANDED:
                return isSetExpanded();
        }
        return super.eIsSet(featureID);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public String toString() {
        if (eIsProxy()) return super.toString();

        StringBuffer result = new StringBuffer(super.toString());
        result.append(" (activePageID: "); //$NON-NLS-1$
        result.append(activePageID);
        result.append(", appearance: "); //$NON-NLS-1$
        if (appearanceESet) result.append(appearance); else result.append("<unset>"); //$NON-NLS-1$
        result.append(", expanded: "); //$NON-NLS-1$
        if (expandedESet) result.append(expanded); else result.append("<unset>"); //$NON-NLS-1$
        result.append(')');
        return result.toString();
    }

} //FolderTypeImpl
